import {FC, useState} from "react";
import {Link, useLocation} from "react-router-dom";
import "./NavComp.less";

const NavComp: FC<any> = () => {
    const location = useLocation();
    const [nav] = useState([
        {name: "数字营商", url: "/home"},
        {name: "智能商圈", url: "/smart_cbd"},
        {name: "精准服务", url: "/risk"},
        {name: "双创地图", url: "/maps"},
    ]);

    return (
        <ul className="nav_box">
            {nav.map((item, index) => {
                return (
                    <li key={index} className={location.pathname.indexOf(item.url) >= 0 ? "active" : ""}>
                        <Link to={item.url}>{item.name}</Link>
                    </li>
                );
            })}
        </ul>
    );
};
export default NavComp;
